<?php
session_start();
header('Content-type:text/html;charset=utf-8');
date_default_timezone_set('PRC');
if(!file_exists('../install/install.lock')){
        header('location:../install/install1.php');
    exit;
 }
include('../public/config/config.php'); 
if(AUTH==2){
    echo "本网站正在维护！请稍后访问";
    exit;
}else if(AUTH==3){
    echo "本网站已关闭，请访问其他网址";
    exit;
}

?>

<!DOCTYPE html>
<html>
	<head>
		<title>
			首页
		</title>
		<meta charset="utf-8"/>
        <link href="./css/index.css" rel="stylesheet" type="text/css"/>
	</head>
	<body>
		<div id="zuishang">
			<div id="shouhang">
				<div id="sheweishouye"><a href="">设为首页</a>&nbsp;<a href="">收藏LAMP兄弟连</a></div>
				<div id="sousuo">
					<ul>
						<li><a href="">搜索</a></li>
						<li><a href="">统计排行</a></li>
						<li><a href="">会员列表</a></li>
						<li><a href="">社区服务</a></li>
						<li><a href="">精华区</a></li>
						<li><a href="">最新帖子</a></li>
						<li><a href="">社区应用</a></li>
						<li><a href="">推广链接</a></li>
						<li id="bang"><a href="">帮助</a></li>
					</ul>
				</div>
			</div>
		</div>	
		<div>
			<div id="hang1">
                <div id="hang1a">
                
                    <a href="./index.php"><img src="../public/config/<?php echo LOGO ?>"></a>
				</div>
				<div id="hang1b"><img src="../public/home/images/wxdbjc.gif">
				</div>
				<div id="hang1c"><img src="../public/home/images/QQzhanghaodenglu.jpg">
                </div>
                
                <div id='hang1d'>
                <?php
                //var_dump($_SESSION);
                 if((!isset($_SESSION['flag'])) || ($_SESSION['flag'] != md5($_SESSION['user']['userName']))){
                     echo "<form method='post' action='dologin 1.php'>
                            <input type='text' name='userName' placeholder='输入用户名'/>&nbsp;
                            <input type='checkbox' name='zhuangtai' value='1' checked/>记住登录&nbsp;<a href=''>找回密码</a>
                            <input type='password' name='passwd' placeholder='密码' id='dd'/>&nbsp;
                            <div>
                                <input type='image' src='../public/home/images/denglu1.jpg'/ '></a>
                                <a href='./register.php'><img src='../public/home/images/zhuce1.jpg'/></a>
                            </div>
                            </from>";

                           //header("Location:./login.php");
                        }else{
                                 $allauth=array(1=>'普通用户',2=>'管理员');
                                ?>
                                   <span style="position:relative;top:5px;">欢迎您，尊贵的会员：<?php echo $_SESSION['userDetail']['name']; ?></span><img src="../public/home/img/<?php echo $_SESSION['userDetail']['photot']; ?>" style="float:right;width:50;height:50px;"><br/>
                                   <span style="position:relative;top:8px;"><a href="./user/usercenter.php?id=<?php echo $_SESSION['user']['id']; ?>">个人中心</a> | <a href="./user/exit.php">退出</a> | <a href="./register.php">注册 </a> | <a href="../admin/index.php">后台管理</a></span><br/>
                            <span style="position:relative;top:10px;">身份：<?php echo $allauth[$_SESSION['user']['auth']]; ?> 积分：<?php echo $_SESSION['userDetail']['score']; ?></span>
                            
                        <?php
                     }
                  ?>
                </div>
                
			</div>
		</div>
		<div id="zhucaidan">
            <div id='nei'>
				<ul>
					<li><a href="">培训课堂</a></li>
					<li><a href="">论坛</a></li>
					<li><a href="">兄弟连云课堂</a></li>
					<li><a href="">PHP视频</a></li>
					<li><a href="">Android视频</a></li>
					<li><a href="">Lunux视频</a></li>
					<li><a href="">Cocos视频</a></li>
					<li><a href="">战地日记</a></li>
					<li><a href="">在线自测</a></li>
						
                </ul>
                <select id="kuai" name="kuaijietongdao">
					<option value="0">
					    快捷通道
					</option>
				</select>
			</div>
        </div>
        <div id="body">
		<div id="hang2">
            <div id="hang2a">
                <img src="../public/home/images/2015-05-12_121141.jpg">
                <form action="./search.php" method="post">
                    <input type="text" name="title" id="search">
                    <select name="" id="tie">
                        <option value="0">
                            帖子
                        </option>
                    </select>
                    <input type="image" src="../public/home/images/sousuo.jpg" name="sousuo" id="sou">
                </form>
            </div>
			<div id="hang2b">热搜：<a href="">php</a>&nbsp;<a href="">php视频</a>&nbsp;<a href="">php教程</a></div>
			<div id="hang2c"><img src="../public/home/images/tu1.png"/></div>
		</div>
		<div id="tu">
			<img id="tu1" src="../public/home/images/main.png">
			<img id="tu2" src="../public/home/images/right_top_left.png">
            <img id="tu3" src="../public/home/images/right_top_right.png">
            <img id="tu5" src="../public/home/images/right_bottom_right.png">
			<img id="tu4" src="../public/home/images/right_bottom_left.png">
			
		</div>
		<div id="tuxia">
			<div id="tuxia1">
				<a href="" id="tuxia1a"><img src="../public/home/images/anc.gif">[视频教程]兄弟连2015版视频发布声明</a>
				<a href="" id="tuxia1b">《明哥聊求职》无节操震撼首发！</a>
				<a href="" id="tuxia1c">兄弟连强势入驻广州</a>
				<a href="" id="tuxia1d">[在线课]兄弟连CTO训练营火热报名中！</a>
			</div>			
			<div id="tuxiazuo">
				<ul>
					<li><a href="">今日：151</a></li>
					<li><a href="">昨日：198</a></li>
					<li><a href="">最高日：116787</a></li>
					<li><a href="">帖子：1347970</a></li>
					<li><a href="">会员：333140</a></li>
					<li><a id="xin" href="">新会员：aycgs027</a></li>
				</ul>
			</div>			
			<div id="tuxiayou">
                <img src="../public/home/images/tubiaomen.jpg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div><a href="">新帖</a> &nbsp;<a href="">精华</a></div>
			</div>
        </div>
        <?php
            include('../install/dbconfig.php');
            mysql_connect(DB_HOST,DB_USER,DB_PASSWD);
            mysql_select_db(DB_NAME);
            mysql_set_charset(DB_CHARSET);
            $SQL="select id,name from type where pid=0 and status=1 order by id ";
            $res=mysql_query($SQL);
            if($res&&mysql_num_rows($res)>0){
                while($arr=mysql_fetch_assoc($res)){
                     
        ?>
        <div class="neirong">
        <div class="neironga"><span>.:::<?php echo $arr['name']; ?>:::.</span><img src="../public/home/images/cate_fold.gif"></div>
            <div class="neirongb">
            <?php
                    $SQL1="select id,name,imgName from type where status=1 and pid='{$arr['id']}' order by id desc ";
                    $res1=mysql_query($SQL1);
                    if($res1&&mysql_num_rows($res1)>0){
                        while($arr1=mysql_fetch_assoc($res1)){
                            
                            //获得版块下的所有非禁用主题数目
                            $SQL2="select count(*) as total from post where recyle=1 and tid='{$arr1['id']}'";
                            $res2=mysql_query($SQL2);
                            $arr2=mysql_fetch_assoc($res2);

                            //获得版块下可看的所有回复的条数
                            $SQL3="select count(*) as tot from post,reply where post.id=reply.pid and post.recyle=1 and post.tid='{$arr1['id']}'";
                            $res3=mysql_query($SQL3);
                            $arr3=mysql_fetch_assoc($res3);

                            //获得今天版块下可看的所有回复的条数
                            $time=strtotime(date('Y-m-d'));
                            $jtime=strtotime(date('Y-m-d'))+24*60*60;
                            $SQL5="select count(*) as tots from post,reply where post.id=reply.pid and post.recyle=1 and post.tid={$arr1['id']} and reply.ctime>{$time} and reply.ctime<{$jtime}";
                            $res5=mysql_query($SQL5);
                            $arr5=mysql_fetch_assoc($res5);

                            //获得版块下的最后一条回复的发布时间
                            $SQL4="select reply.ctime from post,reply where post.id=reply.pid and post.recyle=1 and post.tid='{$arr1['id']}' order by reply.ctime desc limit 1";
                            $res4=mysql_query($SQL4);
                            $arr4=mysql_fetch_assoc($res4);
            ?>
                <div><img src="../admin/post/img/<?php echo $arr1['imgName']; ?>" style="width:57px;height:57px;"><span><a class="lianjie" href="./post/list.php?id=<?php echo $arr1['id'] ?>&pid=<?php echo $arr['id']; ?>&fname=<?php echo $arr['name']?>&bname=<?php echo $arr1['name']; ?>&imgName=<?php echo $arr1['imgName']; ?> "><?php echo $arr1['name'] ?></a>&nbsp;<div style="color:#FF6109;width:70px;float:right;margin-top:15px;">今日（<?php echo $arr5['tots']; ?>）</div><br/>             
                    主题：<?php echo $arr2['total']; ?>&nbsp;帖子：<?php echo $arr3['tot']; ?><br/>
                    最后发帖：<?php echo date('Y-m-d H:i',$arr4['ctime']); ?></span>
                    
                </div>
            <?php
                    }
                }
                ?>                      
            </div>  
        </div>
        <?php
                } 
            }
        
        ?>

        <div id="neirong5">
            <div id="neirong5a"><span style="float:left;">友情链接</span><span style="float:right;width:80px;"><a class="zhu" href="./config/youqing.php">申请链接</a></span></div>
            <div id="neirong5b">
                <img src="../public/home/images/bbs_n.gif"><br/>
                <?php
                    //便利出友情链接的所有链接
                    $SQLL="select * from youqing where stutas=2";
                    $resl=mysql_query($SQLL);
                    if($resl && mysql_num_rows($resl)>0){
                       echo "<div>"; 
                        while($arrl=mysql_fetch_assoc($resl)){
                            echo "<span style='float:left;'><a href='{$arrl['path']}'>{$arrl['name']}</a>&nbsp;</span>";
                        }
                       echo "</div>";
                    }
                ?>    
            </div>
        </div>
            <?php mysql_close(); ?>


        <div id="neirong6">
            <div id="neirong6a"><span>在线用户-共2661人在线,45位会员,2616位访客,最多4931人发生在2013-06-07&nbsp;05:37</span>
            </div>
            <div id="neirong6b">
                <div>
                    <a href=""><img src="../public/home/images/3.gif"><span>司令(管理员)</span></a>&nbsp;&nbsp;
                    <a href=""><img src="../public/home/images/4.gif"><span>连长(超版)</span></a>&nbsp;&nbsp;
                    <a href=""><img src="../public/home/images/5.gif"><span>排长(版主)</span></a>&nbsp;&nbsp;
                    <a href=""><img src="../public/home/images/18.gif"><span>教官</span></a>&nbsp;&nbsp;
                    <a href=""><img src="../public/home/images/10.gif"><span>新兵</span></a>&nbsp;&nbsp;
                    <a href=""><img src="../public/home/images/6.gif"><span>普通会员</span></a>&nbsp;&nbsp;
                    <span><a href="">[打开在线列表]</a></span></div>
            </div>
        </div> 
        <div id="foot">
            <div id="foot1">
                <ul>
                    <li class="xiamiande"><a href="">联系我们</a></li>
                    <li class="xiamiande"><a href="">无图版</a></li>
                    <li class="xiamiande"><a href="">手机浏览</a></li>
                    <li><a href="">清除Cookies</a></li>
                </ul>
            </div>
            <div id="foot2">
                Powered by phpwind v8.7 Certificate Copyright Time now is:<?php echo date('m-d H:i:s',time()); ?><br/>
			&copy;2006-2015 LAMP兄弟连版权所有 Gzip disble 京ICP备11018177号 Total 0.022546(s) query 0,<img src="../public/home/images/pic.gif">
            </div>
        </div>      
        </div>    
</body>
</html>
